*** normal.s	Fri Nov 17 20:10:13 1995
--- tolleuhr.s	Fri Nov 17 20:04:44 1995
***************
*** 1,5 ****
--- 1,150 ----
  ***************************************************************************
  
+ ; tolleuhr.library v37.1 - 15/11/95 by Gunther Nikl - first version
+ 
+ ***************************************************************************
+ 
+ ; include stuff
+ 
+ 		include	exec/types.i
+ 		include	exec/resident.i
+ 		include	exec/libraries.i
+ 		include	exec/initializers.i
+ 		include	lvo30/exec_lib.i
+ 
+ ; specific defines
+ 
+ UHRVER		equ	37
+ UHRREV		equ	1
+ 
+ ; macro stuff
+ 
+ RECALL		MACRO
+ 		jsr	_LVO\1(a6)
+ 		ENDM
+ 
+ LIBVEC		macro
+ 		dc.w	\1-FuncTab
+ 		endm
+ 
+ ; class base
+ 
+ 	STRUCTURE ClassBase,36
+ 
+ 	 ULONG	cb_SegList
+ 	 ULONG	cb_SysBase
+ 
+ 	LABEL cb_SIZEOF
+ 
+ ***************************************************************************
+ 
+ start		moveq	#-1,d0
+ 		rts
+ 
+ ***************************************************************************
+ 
+ RomTag		dc.w	RTC_MATCHWORD
+ 		dc.l	RomTag
+ 		dc.l	EndTag
+ 		dc.b	RTF_AUTOINIT
+ 		dc.b	UHRVER
+ 		dc.b	NT_LIBRARY
+ 		dc.b	0
+ 		dc.l	LibName
+ 		dc.l	IdString
+ 		dc.l	InitTab
+ EndTag
+ 
+ ;--------------------------------------------------------------------------
+ 
+ LibName		dc.b	'tolleuhr.library',0
+ IdString	dc.b	'tolleuhr 37.1 (15.11.95)'
+ 		dc.b	' by M.Fleischer and G.Nikl',13,10,0
+ 
+ ;--------------------------------------------------------------------------
+ 
+ 		cnop	0,4
+ 
+ InitTab		dc.l	cb_SIZEOF
+ 		dc.l	FuncTab
+ 		dc.l	ResInfo
+ 		dc.l	InitFunc
+ 
+ ;--------------------------------------------------------------------------
+ 
+ FuncTab		dc.w	-1
+ 		LIBVEC	LibOpen
+ 		LIBVEC	LibClose
+ 		LIBVEC	LibExpunge
+ 		LIBVEC	LibExtFunc
+ 		LIBVEC	LibClock
+ 		dc.w	-1
+ 
+ ;--------------------------------------------------------------------------
+ 
+ ResInfo		INITBYTE LN_TYPE,NT_LIBRARY
+ 		INITLONG LN_NAME,LibName
+ 		INITBYTE LIB_FLAGS,(LIBF_SUMUSED!LIBF_CHANGED)
+ 		INITWORD LIB_VERSION,UHRVER
+ 		INITWORD LIB_REVISION,UHRREV
+ 		INITLONG LIB_IDSTRING,IdString
+ 		dc.w 0
+ 
+ ***************************************************************************
+ 
+ 		cnop	0,4
+ 
+ InitFunc	suba.l	a1,a1
+ 		cmp.w	#37,20(a6)		; need at least 2.04!
+ 		bcs.s	1$
+ 		move.l	d0,a1
+ 		move.l	a0,cb_SegList(a1)	; save seglist
+ 		move.l	a6,cb_SysBase(a1)	; cache SysBase (speed!)
+ 1$		move.l	a1,d0
+ 		rts
+ 
+ ;--------------------------------------------------------------------------
+ 
+ LibOpen		addq.w	#1,32(a6)		; one more user
+ 		and.b	#$f7,14(a6)
+ 		move.l	a6,d0
+ 		rts
+ ;--------------------------------------------------------------------------
+ 
+ LibClose	subq.w	#1,32(a6)		; one less user
+ 		bne.s	LibExtFunc
+ 		btst	#3,14(a6)
+ 		bne.s	LibExpunge		; expunge!
+ 
+ ;--------------------------------------------------------------------------
+ 
+ LibExtFunc	moveq	#0,d0			; reserved library entry
+ 		rts
+ 
+ ;--------------------------------------------------------------------------
+ 
+ LibExpunge	movem.l	a2/a5/a6,-(sp)
+ 		move.l	a6,a5
+ 		suba.l	a2,a2
+ 		or.b	#8,14(a5)		; set LIBF_DELEXP
+ 		tst.w	32(a5)
+ 		bne.s	1$			; still in use...
+ 		move.l	cb_SysBase(a5),a6
+ 		move.l	cb_SegList(a5),a2	; get seglist
+ 		move.l	a5,a1
+ 		RECALL	Remove
+ 		move.l	a5,a1
+ 		moveq	#0,d0
+ 		move.w	16(a5),d0
+ 		suba.l	d0,a1
+ 		add.w	18(a5),d0
+ 		RECALL	FreeMem
+ 1$		move.l	a2,d0			; return SegList (or NULL)
+ 		movem.l	(sp)+,a2/a5/a6
+ 		rts
+ 
+ ***************************************************************************
+ 
  ; inspired from 'TolleUhr' by Matthias Fleischer - translated to assembler
  ; (gcc is good - I am better ;)
  
***************
*** 11,16 ****
--- 156,162 ----
  ; uhr v1.3   07/03/95 by Gunther Nikl - alarmSet() fixed (didn't set st/mi)
  ;            05/05/95 by Gunther Nikl - optional background image added
  ;            18/05/95 by Gunther Nikl - added 'NOREMAP' switch
+ ;            15/11/95 by Gunther Nikl - first function now '_TolleUhr'
  
  ***************************************************************************
  
***************
*** 18,24 ****
  
  		include	exec/types.i
  		include	lvo30/dos_lib.i
- 		include	lvo30/exec_lib.i
  		include	lvo30/icon_lib.i
  		include	lvo30/locale_lib.i
  		include	lvo30/gadtools_lib.i
--- 164,169 ----
***************
*** 40,49 ****
  		jsr	_LVO\1(a6)
  		ENDM
  
- RECALL		MACRO
- 		jsr	_LVO\1(a6)
- 		ENDM
- 
  MITEM		macro
  		IFEQ	NARG-5
  ItemCount	set	\5
--- 185,190 ----
***************
*** 207,222 ****
  
  ***************************************************************************
  
! 		SECTION start,CODE
! 
! start		move.w	#(gb_SIZEOF>>2)-1,d0
  1$		clr.l	-(sp)			; clear local var area
  		dbra	d0,1$
  		move.l	sp,bp
  		move.l	4,a6
  		move.l	a6,SysBase(bp)		; cache ExecBase
  		suba.l	a1,a1
! 		RECALL	FindTask		; find us
  		move.l	d0,a2
  		move.l	a2,OurTask(bp)		; cache task ptr
  		tst.l	172(a2)
--- 348,362 ----
  
  ***************************************************************************
  
! LibClock	movem.l	d2/a2/a4/a6,-(sp)
! 		move.w	#(gb_SIZEOF>>2)-1,d0
  1$		clr.l	-(sp)			; clear local var area
  		dbra	d0,1$
  		move.l	sp,bp
  		move.l	4,a6
  		move.l	a6,SysBase(bp)		; cache ExecBase
  		suba.l	a1,a1
! 		RECALL	FindTask		; use system function ..
  		move.l	d0,a2
  		move.l	a2,OurTask(bp)		; cache task ptr
  		tst.l	172(a2)
***************
*** 234,239 ****
--- 374,380 ----
  		RECALL	ReplyMsg		; reply wbsmg
  1$		moveq	#0,d0
  		lea	gb_SIZEOF(bp),sp
+ 		movem.l	(sp)+,d2/a2/a4/a6
  		rts
  
  ***************************************************************************
